<template>
  <div>
    <h2 align="center">会员信息修改</h2>
    <table border="1" align="center">
      <tr>
        <td>会员名称</td>
        <td>
          <input type="text" v-model="state.name">
        </td>
      </tr>
      <tr>
        <td>年龄</td>
        <td>
          <input type="text" v-model="state.age">
        </td>
      </tr>
      <tr>
        <td>出生日期</td>
        <td>
          <input type="date" v-model="state.date">
        </td>
      </tr>
      <tr>
        <td>状态</td>
        <td>
          <input type="radio" value="停用" name="a_State" v-model="state.zhuang">停用
          <input type="radio" value="启用" name="a_State" checked v-model="state.zhuang">启用
        </td>
      </tr>
      <tr>
        <td></td>
        <td>
          <input type="button" value="修改" @click="UpdateInfo">
        </td>
      </tr>
    </table>
  </div>
</template>

<script setup lang="ts">
import { onMounted, reactive,toRefs } from 'vue';
import axios from 'axios';
import { useRouter } from 'vue-router';
const router = useRouter()

let data = reactive({
  state:{
    name:'',
    age:'',
    date:'',
    zhuang:1
  }
})
let {state} = toRefs(data)

onMounted(()=>{
  Fan(id)
})

const Fan=(id:any)=>{
  axios({
    url:'/api/Member/Fantian',
    method:'',
    params:{
      aid:id
    }
  })
  .then(res=>{
    console.log(res)
    
  })
  .catch(err=>{
    console.log(err)
  })
}

const UpdateInfo=()=>{
  axios({
    url:'/api/Member/PutAdminInfo',
    method:'post',
    data:state.value
  })
  .then(res=>{
    if(res.data.data > 0){
      alert("修改成功");
      router.push('/adminList')
    }
    else{
      alert("修改失败");
      return;
    }
  })
}
</script>

<style scoped>

</style>